package com.haima.ziliao.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.haima.common.annotation.Log;
import com.haima.common.core.controller.BaseController;
import com.haima.common.core.domain.AjaxResult;
import com.haima.common.enums.BusinessType;
import com.haima.ziliao.domain.PKevideos;
import com.haima.ziliao.service.IPKevideosService;
import com.haima.common.utils.poi.ExcelUtil;
import com.haima.common.core.page.TableDataInfo;

/**
 * 课程视频Controller
 * 
 * @author hima
 * @date 2024-10-21
 */
@RestController
@RequestMapping("/ziliao/kevideos")
public class PKevideosController extends BaseController
{
    @Autowired
    private IPKevideosService pKevideosService;

    /**
     * 查询课程视频列表
     */
    @PreAuthorize("@ss.hasPermi('ziliao:kevideos:list')")
    @GetMapping("/list")
    public TableDataInfo list(PKevideos pKevideos)
    {
        startPage();
        List<PKevideos> list = pKevideosService.selectPKevideosList(pKevideos);
        return getDataTable(list);
    }

    /**
     * 导出课程视频列表
     */
    @PreAuthorize("@ss.hasPermi('ziliao:kevideos:export')")
    @Log(title = "课程视频", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PKevideos pKevideos)
    {
        List<PKevideos> list = pKevideosService.selectPKevideosList(pKevideos);
        ExcelUtil<PKevideos> util = new ExcelUtil<PKevideos>(PKevideos.class);
        util.exportExcel(response, list, "课程视频数据");
    }

    /**
     * 获取课程视频详细信息
     */
    @PreAuthorize("@ss.hasPermi('ziliao:kevideos:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(pKevideosService.selectPKevideosById(id));
    }

    /**
     * 新增课程视频
     */
    @PreAuthorize("@ss.hasPermi('ziliao:kevideos:add')")
    @Log(title = "课程视频", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PKevideos pKevideos)
    {
        return toAjax(pKevideosService.insertPKevideos(pKevideos));
    }

    /**
     * 修改课程视频
     */
    @PreAuthorize("@ss.hasPermi('ziliao:kevideos:edit')")
    @Log(title = "课程视频", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PKevideos pKevideos)
    {
        return toAjax(pKevideosService.updatePKevideos(pKevideos));
    }

    /**
     * 删除课程视频
     */
    @PreAuthorize("@ss.hasPermi('ziliao:kevideos:remove')")
    @Log(title = "课程视频", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(pKevideosService.deletePKevideosByIds(ids));
    }
}
